<!--
 * @Description: 
 * @Date: 2024-04-09 15:56:06
 * @LastEditTime: 2024-11-01 17:50:02
-->
<template>
  <div class="digitization">
    <div class="digitization-header">
      <h1>智慧人大数字化平台</h1>
    </div>
    <div class="digitization-content">
      <div class="digitization-content-left">
        <div>
          <div class="dItem-title">
            <span>代表情况</span
            ><span @click="handleSkip('/representative')">更多></span>
          </div>
          <div class="dItem-left1">
            <div>
              <div>
                <p>代表人数</p>
                <p>{{ numberCount.userCount }}人</p>
              </div>
              <div>
                <p>今年履职次数</p>
                <p>{{ numberCount.lvZhiCount }}人次</p>
              </div>
            </div>
            <div>
              <pie className="pie" :chartData="leftOneData"></pie>
            </div>
          </div>
        </div>
        <div>
          <div class="dItem-title">
            <span>建议议案</span
            ><span @click="handleSkip('/proposal')">更多></span>
          </div>
          <div class="dItem-left2">
            <div>
              <div>
                <p>今年议案建议总数</p>
                <p>{{ numberCount.yiAnCount }}人次</p>
              </div>
              <div>
                <div>
                  <p>办理中</p>
                  <p>109件</p>
                </div>
                <div>
                  <p>办理中</p>
                  <p>109件</p>
                </div>
              </div>
            </div>
            <div>
              <pie className="homePie" :chartData="leftTwoData"></pie>
            </div>
          </div>
        </div>
      </div>
      <div class="digitization-content-center">
        <div>
          <div>
            <p>联络站总数</p>
            <p>
              <CountTo
                :startVal="0"
                :endVal="numberCount.lianLuoCount"
                :duration="4000"
              /><span>个</span>
            </p>
          </div>
          <div>
            <p>代表总数</p>
            <p>
              <CountTo
                :startVal="0"
                :endVal="numberCount.userCount"
                :duration="4000"
              /><span>人</span>
            </p>
          </div>
          <div>
            <p>立法工作</p>
            <p>
              <CountTo
                :startVal="0"
                :endVal="numberCount.lvZhiCount"
                :duration="4000"
              /><span>人次</span>
            </p>
          </div>
          <div>
            <p>议案建议</p>
            <p>
              <CountTo
                :startVal="0"
                :endVal="numberCount.yiAnCount"
                :duration="2000"
              /><span>人次</span>
            </p>
          </div>
        </div>
        <div>
          <centerMap className="centerMap" @getCount="getCount"></centerMap>
        </div>
      </div>
      <div class="digitization-content-right">
        <div>
          <div class="dItem-title">
            <span>立法工作</span
            ><span @click="handleSkip('/law')">更多></span>
          </div>
          <div class="dItem-right1">
            <div>
              <div>
                <!-- <span>代表人数</span>
                <span
                  >---------------------------------------------------------------------</span
                >
                <span>1505人</span>
              </div>
              <div>
                <span>今年履职次数</span>
                <span
                  >----------------------------------------------------------------------------</span
                >
                <span>1505人</span> -->
              </div>
            </div>
            <div>
              <pie className="bar" :chartData="rightBarData"></pie>
            </div>
          </div>
        </div>
        <div>
          <div class="dItem-title">
            <span>社情民意</span
            ><span @click="handleSkip('/social')">更多></span>
          </div>
          <div class="dItem-left2">
            <div>
              <div>
                <p>今年议案建议总数</p>
                <p>109人次</p>
              </div>
              <div>
                <div>
                  <p>办理中</p>
                  <p>109件</p>
                </div>
                <div>
                  <p>办理中</p>
                  <p>109件</p>
                </div>
              </div>
            </div>
            <div>
              <pie className="homePie1" :chartData="rightPieData"></pie>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div
      class="skipHou"
      @click="
        () => {
          this.$messageBox.hide();
          this.$router.push('/index');
        }
      "
    >
      <img src="../../assets/images/back.png" />
      <p>首页</p>
    </div>
  </div>
</template>

<script>
import CountTo from "vue-count-to";
import pie from "./components/home/pie.vue";

import centerMap from "./components/centerMap.vue";
import autofit from "autofit.js";
import {
  leftOneData,
  leftTwoData,
  rightBar,
  rightPie,
} from "./components/home/homeData";
import {
  levelCount,
  suggestType,
  lzCount,
  userCount,
  contactStationList,
} from "@/api/digitization/home/index";
import { number } from "echarts";
export default {
  components: {
    pie,
    centerMap,
    CountTo,
  },
  data() {
    return {
      leftOneData: null,
      leftTwoData: null,
      rightBarData: null,
      rightPieData: null,
      centerMapData: null,
      numberCount: {
        userCount: 0,
        lvZhiCount: 0,
        lianLuoCount: 0,
        yiAnCount: 0,
      },
    };
  },
  created() {
    levelCount().then((res) => {
      this.leftOneData = leftOneData(res.rows);
    });
    suggestType().then((res) => {
      this.leftTwoData = leftTwoData(res.rows, true);
      this.numberCount.yiAnCount = this.getNumber(res.rows);
    });
    lzCount().then((res) => {
      this.rightBarData = rightBar(res.rows);
      this.numberCount.lvZhiCount = this.getNumber(res.rows);
    });
    userCount().then((res) => {
      this.numberCount.userCount = res;
    });
    this.rightPieData = rightPie();
  },
  mounted() {
    autofit.init({
      dh: 1080,
      dw: 1920,
      el: ".digitization",
      resize: true,
    });
  },
  methods: {
    handleSkip(path) {
      this.$messageBox.hide();
      this.$router.push({ path });
    },
    getCount(value) {
      this.numberCount.lianLuoCount = value && value;
    },
    getNumber(rows) {
      return rows.length > 0
        ? rows.reduce(
            (accumulator, currentValue) =>
              accumulator + Number(currentValue.count),
            0
          )
        : 0;
    },
  },
};
</script>
<style lang="scss" scoped>
.digitization {
  width: 100%;
  height: 100%;
  background: #021132;
  display: flex;
  flex-direction: column;

  &-header {
    width: 100%;
    height: 100px;
    background-image: url("../../assets/images/digitzation/top.png");
    background-size: 100% 100%;
    background-repeat: no-repeat;
    display: flex;
    justify-content: center;
    align-items: center;
    h1 {
      margin-top: 10px;
      font-weight: bold;
      letter-spacing: 5px;
      color: #fff;
    }
  }
  &-content {
    width: 100%;
    flex: 1;
    padding: 0 30px 10px 30px;
    margin-top: 30px;
    box-sizing: border-box;
    overflow: hidden;
    display: flex;
    &-left,
    &-right {
      width: 25%;
      height: 100%;
      display: grid;
      grid-template-columns: 1fr;
      grid-template-rows: repeat(2, 1fr);
      grid-gap: 30px;
      & > div {
        background: yellow;
        background: url("../../assets/images/digitzation/frame.png") no-repeat;
        background-size: 100% 100%;
        padding: 15px 20px;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        .dItem-title {
          line-height: 45px;
          margin-left: 10px;
          color: #fff;
          font-weight: bold;
          font-size: 18px;
          display: flex;
          justify-content: space-between;
        }
        .dItem-left1 {
          width: 100%;
          flex: 1;
          display: flex;

          & > div:nth-child(1) {
            width: 30%;
            height: 100%;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            & > div {
              display: flex;
              flex-direction: column;
              align-items: center;
              color: #fff;
              & > p:nth-child(1) {
                font-size: 16px;
                margin-bottom: 15px;
              }
              & > p:nth-child(2) {
                font-size: 22px;
                font-weight: bold;
              }
            }
            & > div:nth-child(1) {
              margin-bottom: 30px;
            }
          }
          & > div:nth-child(2) {
            height: 100%;
            flex: 1;
          }
        }
        .dItem-left2 {
          width: 100%;
          flex: 1;
          display: flex;
          & > div:nth-child(1) {
            width: 30%;
            margin-right: 2%;
            display: flex;
            flex-direction: column;
            justify-content: center;
            & > div:nth-child(1) {
              color: #fff;
              display: flex;
              flex-direction: column;
              align-items: center;
              & > p:nth-child(1) {
                font-size: 16px;
                margin-bottom: 15px;
              }
              & > p:nth-child(2) {
                font-size: 22px;
                font-weight: bold;
              }
            }
            & > div:nth-child(2) {
              display: flex;
              justify-content: space-between;
              margin-top: 40px;
              color: #fff;
              & > div {
                color: #fff;
                & > p:nth-child(1) {
                  font-size: 16px;
                  margin-bottom: 15px;
                }
                & > p:nth-child(2) {
                  font-size: 22px;
                  font-weight: bold;
                }
              }
            }
          }
          & > div:nth-child(2) {
            height: 100%;
            flex: 1;
          }
        }
        .dItem-right1 {
          width: 100%;
          flex: 1;
          display: flex;
          flex-direction: column;
          overflow: hidden;

          & > div:nth-child(1) {
            width: 100%;
            color: #fff;
            margin-top: 10px;
            padding: 0 40px;
            box-sizing: border-box;
            & > div {
              display: flex;
              align-items: center;
              & > span:nth-child(1) {
                font-size: 16px;
              }
              & > span:nth-child(2) {
                flex: 1;
                white-space: nowrap;
                overflow: hidden;
              }
              & > span:nth-child(3) {
                font-size: 24px;
              }
            }
          }
          & > div:nth-child(2) {
            width: 100%;
            flex: 1;
            overflow: hidden;
          }
        }
      }
    }
    &-center {
      height: 100%;
      flex: 1;
      margin: 0 10px;
      display: flex;
      flex-direction: column;
      & > div:nth-child(1) {
        width: 100%;
        height: 150px;
        margin-bottom: 20px;
        background: url("../../assets/images/digitzation/center1.png") no-repeat;
        background-size: 100% 100%;
        padding: 15px 20px;
        box-sizing: border-box;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        grid-template-rows: 1fr;
        grid-gap: 10px;
        & > div {
          color: #fff;
          display: flex;
          flex-direction: column;
          justify-content: space-evenly;
          align-items: center;
          & > p:nth-child(1) {
            font-size: 20px;
          }
          & > p:nth-child(2) {
            span:nth-child(1) {
              font-size: 30px;
              font-weight: bold;
            }
            span:nth-child(2) {
              font-size: 16px;
              font-weight: bold;
            }
          }
        }
      }
      & > div:nth-child(2) {
        width: 100%;
        flex: 1;
        background: url("../../assets/images/digitzation/center2.png") no-repeat;
        background-size: 100% 100%;
        padding: 15px 20px;
      }
    }
  }
  .skipHou {
    position: absolute;
    top: 70px;
    right: 50px;
    display: flex;
    justify-content: center;
    align-items: center;

    color: #fff;
    font-size: 18px;
    font-weight: bold;
    img {
      width: 30px;
      margin-right: 10px;
    }
  }
}
</style>
